package com.zdxf.controller;

import com.zdxf.conf.Constant;
import com.zdxf.domain.MenuDO;
import com.zdxf.service.impl.MenuServiceImpl;
import com.zdxf.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/menu")
@Api(tags = "用户菜单权限管理")
public class MenuController {

    @Autowired
    private MenuServiceImpl menuService;

    Result result = Constant.RESULT_EMPTY;
    /**
     * 菜单列表
     */
    @ApiOperation(value = "菜单列表", notes = "菜单列表")
    @GetMapping("/list")
    public Object list() {
        return menuService.getList();
    }
    /**
     * 父级菜单列表
     */
    @ApiOperation(value = "父级菜单列表", notes = "父级菜单列表")
    @GetMapping("/parentList")
    public Object parentList() {
        return menuService.parentList();
    }


    /**
     * 新增菜单
     */
    @ApiOperation(value = "新增菜单", notes = "新增菜单")
    @PostMapping("/add")
    public Object addRole(@RequestBody MenuDO menuBody) {
        return menuService.addMenu(menuBody);
    }

    /**
     * 编辑菜单
     */
    @ApiOperation(value = "编辑菜单", notes = "编辑菜单")
    @PutMapping("/update")
    public Object updateMenu(@RequestBody MenuDO menuBody) {
        return menuService.updateMenu(menuBody);
    }

    /**
     *删除菜单
     */
    @ApiOperation(value = "删除菜单", notes = "删除菜单")
    @DeleteMapping("/delete")
    public Object deleteMenu(@RequestParam("id") long id) {
        return menuService.deleteMenu(id);
    }

}
